/**
 * 解析定时透传 Hex 指令
 */
export function parseTimingRaw(hex: string): {
  isOn: number;
  hour: number;
} {
  if (hex.length < 4) return { isOn: 0, hour: 0 };
  const isOn = parseInt(hex.slice(0, 2), 16);
  const hour = parseInt(hex.slice(2, 4), 16);
  return {
    isOn,
    hour,
  };
}

export function parseWorkRaw(hex: string): {
  gear: number;
  start: number;
  pause: number;
} {
  if (hex.length < 6) {
    return {
      gear: 0,
      start: 0,
      pause: 0,
    };
  }
  const gear = parseInt(hex.slice(0, 2), 16);
  const start = parseInt(hex.slice(2, 4), 16);
  const pause = parseInt(hex.slice(4, 6), 16);
  return {
    gear,
    start,
    pause,
  };
}
